package 网络编程.综合练习.多发多收;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class 发送数据 {
    public static void main(String[] args) throws IOException {
        //1.建立发送数据的连接的通道
        Socket socket=new Socket("127.0.0.1",10086);

        //2.从连接通道获取输出流
        Scanner sc=new Scanner(System.in);
        OutputStream os = socket.getOutputStream();
        while (true){
            System.out.print("请输入要发送的内容:");
            String data = sc.next();
            //写入要发送的数据;
            os.write(data.getBytes());
        }
    }
}
